<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>项目保函开具</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="enginid_name" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">保证金类型</label>
                        <div class="layui-input-block">
                            <input type="text" id="bondtype" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">保函类别</label>
                        <div class="layui-input-block">
                            <input type="text" id="hantype" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>保函金额(元)</label>
                        <div class="layui-input-block">
                             <input type="text" id="money" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">保证金截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" id="jiedt" placeholder="请输入" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">手续费(元)</label>
                        <div class="layui-input-block">
                            <input type="text" name="shoufee" id="shoufee" placeholder="请输入" autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">受益人</label>
                        <div class="layui-input-block">
                            <input type="text" name="shouer" id="shouer" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">被担保人</label>
                        <div class="layui-input-block">
                            <input type="text" name="beidaner" id="beidaner" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">担保人</label>
                        <div class="layui-input-block">
                            <input type="text" name="daner" id="daner" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>开具日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaidt" id="kaidt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>有效期</label>
                        <div class="layui-input-block">
                            <input type="text" name="xiaodt" id="xiaodt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">备注</label>
                        <div class="layui-input-block">
                            <textarea id="explain" name="explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <?php include '../public/upinfo.php'?>
        </div>


    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;

    $("#commentForm").validate({
        rules: {
            kaidt: {required: true},
            xiaodt: {required: true},
        },
        messages:{
            kaidt: {required: "请选择"},
            xiaodt: {required: "请选择"},
        }
    });


    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_engin_bond_kai_kai,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                var engininfo = res.data.engininfo;

                $("#enginid_name").val(engininfo.name);

                $("#bondtype").val(data.bondtype);
                $("#hantype").val(data.hantype);
                $("#money").val(data.money);
                $("#shouer").val(data.shouer);
                $("#beidaner").val(data.beidaner);
                $("#daner").val(data.daner);
                $("#kaidt").val(data.kaidt);
                $("#xiaodt").val(data.xiaodt);
                $("#shoufee").val(data.shoufee);
                $("#explain").val(data.explain);
                $("#jiedt").val(data.jiedt);


                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });


        form.on('submit(add)', function(data){
            var validRes = $("#commentForm").valid();
            if(!validRes){return false;}

            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            facade.ajax({url: ask_engin_bond_kai_kai, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });


</script>
</body>
</html>
